// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file DdsRecorderMonitoringStatusTypeObjectSupport.cxx
 * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file
 *
 * This file was generated by the tool fastddsgen.
 */

#include <ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp>

#include <mutex>
#include <string>

#include <fastcdr/xcdr/external.hpp>
#include <fastcdr/xcdr/optional.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/dds/xtypes/common.hpp>
#include <fastdds/dds/xtypes/type_representation/ITypeObjectRegistry.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp>

#include <ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatus.hpp>

#include "ddspipe_core/types/monitoring/status/MonitoringStatus.hpp"

using namespace eprosima::fastdds::dds::xtypes;

// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_DdsRecorderMonitoringErrorStatus_type_identifier(
        TypeIdentifierPair& type_ids_DdsRecorderMonitoringErrorStatus)
{

    ReturnCode_t return_code_DdsRecorderMonitoringErrorStatus {eprosima::fastdds::dds::RETCODE_OK};
    return_code_DdsRecorderMonitoringErrorStatus =
        eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
        "DdsRecorderMonitoringErrorStatus", type_ids_DdsRecorderMonitoringErrorStatus);
    if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderMonitoringErrorStatus)
    {
        StructTypeFlag struct_flags_DdsRecorderMonitoringErrorStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
                false, false);
        QualifiedTypeName type_name_DdsRecorderMonitoringErrorStatus = "DdsRecorderMonitoringErrorStatus";
        eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_DdsRecorderMonitoringErrorStatus;
        eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_DdsRecorderMonitoringErrorStatus;
        CompleteTypeDetail detail_DdsRecorderMonitoringErrorStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderMonitoringErrorStatus, ann_custom_DdsRecorderMonitoringErrorStatus, type_name_DdsRecorderMonitoringErrorStatus.to_string());
        CompleteStructHeader header_DdsRecorderMonitoringErrorStatus;
        header_DdsRecorderMonitoringErrorStatus = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsRecorderMonitoringErrorStatus);
        CompleteStructMemberSeq member_seq_DdsRecorderMonitoringErrorStatus;
        {
            TypeIdentifierPair type_ids_mcap_file_creation_failure;
            ReturnCode_t return_code_mcap_file_creation_failure {eprosima::fastdds::dds::RETCODE_OK};
            return_code_mcap_file_creation_failure =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "_bool", type_ids_mcap_file_creation_failure);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_mcap_file_creation_failure)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                        "mcap_file_creation_failure Structure member TypeIdentifier unknown to TypeObjectRegistry.");
                return;
            }
            StructMemberFlag member_flags_mcap_file_creation_failure = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
                    false, false, false, false);
            MemberId member_id_mcap_file_creation_failure = 0x00000000;
            bool common_mcap_file_creation_failure_ec {false};
            CommonStructMember common_mcap_file_creation_failure {TypeObjectUtils::build_common_struct_member(member_id_mcap_file_creation_failure, member_flags_mcap_file_creation_failure, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_mcap_file_creation_failure, common_mcap_file_creation_failure_ec))};
            if (!common_mcap_file_creation_failure_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure mcap_file_creation_failure member TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_mcap_file_creation_failure = "mcap_file_creation_failure";
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_mcap_file_creation_failure;
            ann_custom_DdsRecorderMonitoringErrorStatus.reset();
            CompleteMemberDetail detail_mcap_file_creation_failure = TypeObjectUtils::build_complete_member_detail(name_mcap_file_creation_failure, member_ann_builtin_mcap_file_creation_failure, ann_custom_DdsRecorderMonitoringErrorStatus);
            CompleteStructMember member_mcap_file_creation_failure = TypeObjectUtils::build_complete_struct_member(common_mcap_file_creation_failure, detail_mcap_file_creation_failure);
            TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderMonitoringErrorStatus, member_mcap_file_creation_failure);
        }
        {
            TypeIdentifierPair type_ids_disk_full;
            ReturnCode_t return_code_disk_full {eprosima::fastdds::dds::RETCODE_OK};
            return_code_disk_full =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "_bool", type_ids_disk_full);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_disk_full)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                        "disk_full Structure member TypeIdentifier unknown to TypeObjectRegistry.");
                return;
            }
            StructMemberFlag member_flags_disk_full = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
                    false, false, false, false);
            MemberId member_id_disk_full = 0x00000001;
            bool common_disk_full_ec {false};
            CommonStructMember common_disk_full {TypeObjectUtils::build_common_struct_member(member_id_disk_full, member_flags_disk_full, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_disk_full, common_disk_full_ec))};
            if (!common_disk_full_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure disk_full member TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_disk_full = "disk_full";
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_disk_full;
            ann_custom_DdsRecorderMonitoringErrorStatus.reset();
            CompleteMemberDetail detail_disk_full = TypeObjectUtils::build_complete_member_detail(name_disk_full, member_ann_builtin_disk_full, ann_custom_DdsRecorderMonitoringErrorStatus);
            CompleteStructMember member_disk_full = TypeObjectUtils::build_complete_struct_member(common_disk_full, detail_disk_full);
            TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderMonitoringErrorStatus, member_disk_full);
        }
        CompleteStructType struct_type_DdsRecorderMonitoringErrorStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderMonitoringErrorStatus, header_DdsRecorderMonitoringErrorStatus, member_seq_DdsRecorderMonitoringErrorStatus);
        if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderMonitoringErrorStatus, type_name_DdsRecorderMonitoringErrorStatus.to_string(), type_ids_DdsRecorderMonitoringErrorStatus))
        {
            EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                    "DdsRecorderMonitoringErrorStatus already registered in TypeObjectRegistry for a different type.");
        }
    }
}
// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_DdsRecorderMonitoringStatus_type_identifier(
        TypeIdentifierPair& type_ids_DdsRecorderMonitoringStatus)
{

    ReturnCode_t return_code_DdsRecorderMonitoringStatus {eprosima::fastdds::dds::RETCODE_OK};
    return_code_DdsRecorderMonitoringStatus =
        eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
        "DdsRecorderMonitoringStatus", type_ids_DdsRecorderMonitoringStatus);
    if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderMonitoringStatus)
    {
        StructTypeFlag struct_flags_DdsRecorderMonitoringStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
                false, false);
        return_code_DdsRecorderMonitoringStatus =
            eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
            "MonitoringStatus", type_ids_DdsRecorderMonitoringStatus);

        if (return_code_DdsRecorderMonitoringStatus != eprosima::fastdds::dds::RETCODE_OK)
        {
::register_MonitoringStatus_type_identifier(type_ids_DdsRecorderMonitoringStatus);
        }
        QualifiedTypeName type_name_DdsRecorderMonitoringStatus = "DdsRecorderMonitoringStatus";
        eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_DdsRecorderMonitoringStatus;
        eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_DdsRecorderMonitoringStatus;
        CompleteTypeDetail detail_DdsRecorderMonitoringStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderMonitoringStatus, ann_custom_DdsRecorderMonitoringStatus, type_name_DdsRecorderMonitoringStatus.to_string());
        CompleteStructHeader header_DdsRecorderMonitoringStatus;
        if (EK_COMPLETE == type_ids_DdsRecorderMonitoringStatus.type_identifier1()._d())
        {
            header_DdsRecorderMonitoringStatus = TypeObjectUtils::build_complete_struct_header(type_ids_DdsRecorderMonitoringStatus.type_identifier1(), detail_DdsRecorderMonitoringStatus);
        }
        else if (EK_COMPLETE == type_ids_DdsRecorderMonitoringStatus.type_identifier2()._d())
        {
            header_DdsRecorderMonitoringStatus = TypeObjectUtils::build_complete_struct_header(type_ids_DdsRecorderMonitoringStatus.type_identifier2(), detail_DdsRecorderMonitoringStatus);
        }
        else
        {
            EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                    "DdsRecorderMonitoringStatus Structure: base_type TypeIdentifier registered in TypeObjectRegistry is inconsistent.");
            return;
        }
        CompleteStructMemberSeq member_seq_DdsRecorderMonitoringStatus;
        {
            TypeIdentifierPair type_ids_ddsrecorder_error_status;
            ReturnCode_t return_code_ddsrecorder_error_status {eprosima::fastdds::dds::RETCODE_OK};
            return_code_ddsrecorder_error_status =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "DdsRecorderMonitoringErrorStatus", type_ids_ddsrecorder_error_status);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_ddsrecorder_error_status)
            {
            ::register_DdsRecorderMonitoringErrorStatus_type_identifier(type_ids_ddsrecorder_error_status);
            }
            StructMemberFlag member_flags_ddsrecorder_error_status = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
                    false, false, false, false);
            MemberId member_id_ddsrecorder_error_status = 0x00000002;
            bool common_ddsrecorder_error_status_ec {false};
            CommonStructMember common_ddsrecorder_error_status {TypeObjectUtils::build_common_struct_member(member_id_ddsrecorder_error_status, member_flags_ddsrecorder_error_status, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_ddsrecorder_error_status, common_ddsrecorder_error_status_ec))};
            if (!common_ddsrecorder_error_status_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure ddsrecorder_error_status member TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_ddsrecorder_error_status = "ddsrecorder_error_status";
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_ddsrecorder_error_status;
            ann_custom_DdsRecorderMonitoringStatus.reset();
            CompleteMemberDetail detail_ddsrecorder_error_status = TypeObjectUtils::build_complete_member_detail(name_ddsrecorder_error_status, member_ann_builtin_ddsrecorder_error_status, ann_custom_DdsRecorderMonitoringStatus);
            CompleteStructMember member_ddsrecorder_error_status = TypeObjectUtils::build_complete_struct_member(common_ddsrecorder_error_status, detail_ddsrecorder_error_status);
            TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderMonitoringStatus, member_ddsrecorder_error_status);
        }
        CompleteStructType struct_type_DdsRecorderMonitoringStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderMonitoringStatus, header_DdsRecorderMonitoringStatus, member_seq_DdsRecorderMonitoringStatus);
        if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderMonitoringStatus, type_name_DdsRecorderMonitoringStatus.to_string(), type_ids_DdsRecorderMonitoringStatus))
        {
            EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                    "DdsRecorderMonitoringStatus already registered in TypeObjectRegistry for a different type.");
        }
    }
}

